<?php
include('../../inc/global.inc');
include("../islogin.php");
$url=$_SERVER['HTTP_REFERER'];
?>
<?php
if($_POST[act_tj]){
     $type_id=$_POST[type_id]?$_POST[type_id]:0;
     @mysql_query("insert into dh_type (type_name,type_id) values ('$_POST[type_name]','$type_id')");
     echo "<script>location='".$_POST[url]."';</script>";
}
?>
<?php
if($_POST['act_xg']){
     $type_id=$_POST[type_id]?$_POST[type_id]:0;
     @mysql_query("update dh_type set type_name='$_POST[type_name]',type_id='$type_id' where id='".$_POST['iid']."'");
     echo "<script>location='".$_POST[url]."';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
</HEAD>
<BODY>
<center>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">导航分类&nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
<?php
if($_GET[tj]){
?>
  <table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
  <form method="post" action="" name="form1">
    <tr>
      <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">添加导航分类</td>
    </tr>
    <tr>
      <td width="26%" height="30" align="center" bgcolor="#FFFFFF">分类名称</td>
      <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="type_name" type="text" id="type_name" size="30" maxlength="100"></td>
    </tr>
	 <tr>
      <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
      <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><select name="type_id">
  <option value="0" selected>--选择上级目录--</option>
  <?php
  $sql="select * from dh_type where type_id=0 order by id asc";
  $rs=@mysql_query($sql);
  while($row=@mysql_fetch_array($rs)){
  ?><option value="<?=$row['id']?>" <?php if($_GET[id]==$row['id']){echo "selected";}?>><?=$row[type_name]?></option>
  
  <?php
         $sql2="select * from dh_type where type_id='".$row['id']."' order by id asc";
		 $rs2=mysql_query($sql2);
		 while($row2=mysql_fetch_array($rs2)){
       ?><option value="<?=$row2['id']?>" <?php if($_GET[id]==$row2[id]){echo "selected";}?>>&nbsp;&nbsp;&nbsp;&nbsp;|--<?=$row2[type_name]?></option>
  <?php }}
  ?>
      </select></td>
    </tr>	
    <tr><input type="hidden" name="url" value="<?=$url?>">
	<input type="hidden" name="act_tj" value="ok">
      <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" value="提交"></td>
    </tr>
	</form>
  </table>
  <?php
}
?>
  <?php
if($_GET['xg']){
$sql="select * from dh_type where id=".$_GET['xg_id'];
$rs=mysql_query($sql);
$row=mysql_fetch_array($rs)
?>
<table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <form method="post" action="" name="form1">
      <tr>
        <td height="30" colspan="2" align="center" bgcolor="#8DA8CF">修改导航分类</td>
      </tr>
      <tr>
        <td width="27%" height="30" align="center" bgcolor="#FFFFFF">分类名称</td>
        <td width="74%" align="left" bgcolor="#FFFFFF" style="padding-left:2px;"><input name="type_name" type="text" value="<?=$row[type_name]?>" size="30" maxlength="100"></td>
      </tr>
      <tr>
        <td height="30" align="center" bgcolor="#FFFFFF">上级目录</td>
        <td align="left" bgcolor="#FFFFFF" style="padding-left:2px;">
		<select name="type_id">
            <option value="0">--选择上级目录--</option>
  <?php
  $sql2="select * from dh_type where type_id=0 order by id asc";
  $rs2=mysql_query($sql2);
  while($row2=mysql_fetch_array($rs2)){
  ?>
          <option value="<?=$row2['id']?>" <?php if($row2[id]==$row[type_id]){echo "selected";}?>><?=$row2[type_name]?></option>
	<?php
	$rs3=@mysql_query("select * from dh_type where type_id='$row2[id]'");
    while($row3=@mysql_fetch_array($rs3)){?>
          <option value="<?=$row3['id']?>" <?php if($row3[id]==$row[type_id]){echo "selected";}?>>------<?=$row3[type_name]?></option>
  <?php }}?>
        </select></td>
      </tr>
      <tr><input type="hidden" name="url" value="<?=$url?>">
        <input type="hidden" name="act_xg" value="ok"><input type="hidden" name="iid" value="<?=$row['id']?>">
        <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><input name="submit" type="submit" value="提交"></td>
      </tr>
    </form>
  </table>
  <?php }?>
</center>
</BODY>
</HTML>
